package com.xd.dubai.api.controller;

import com.xd.dubai.api.entity.ApiHealthyInfoEntity;
import com.xd.dubai.api.controller.innate.ApiHealthyInfoInnateAbs;
import com.dt.dubai.core.comm.*;
import com.dt.dubai.core.utile.DateTools;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Date;
import java.util.List;
import java.util.Map;

/*
* 个人基本信息表
*/

@Controller
@RequestMapping(value = "/api/apiHealthyInfo")
public class ApiHealthyInfoController extends ApiHealthyInfoInnateAbs {

    /*innateServiceStart*/
    @Override
    protected void userSavEntity(ApiHealthyInfoEntity inEntity, final Long userId) {
        inEntity.setDelSign(false);
    }

    @Override
    protected void userModEntity(ApiHealthyInfoEntity inEntity, final Long userId) {
    }

    @Override
    protected void userDelByKey(List<Long> recordIds, final Long userId) {
    }

    @Override
    protected void userQueByKey(Long recordId, Map<String, Object> map, final Long userId) {
        if (null != map && map.size() > 0) {
            map.put("createTxStamp", DateTools.dateFormat((Date) map.get("createTxStamp"), DateTools.DATE_FORMAT_YMD));
            map.remove("healthRecordRecordId");
            map.remove("delSign");
            map.remove("lastupTxStamp");
        }
    }

    @Override
    protected void userQuePageList(PageParameterData queryCondition, List<PageCondition> joinCondition, List<Map<String, Object>> resultMap, final Long userId) {
        for (Map<String, Object> map : resultMap) {
            map.put("createTxStamp", DateTools.dateFormat((Date) map.get("createTxStamp"), DateTools.DATE_FORMAT_YMD));
            map.remove("healthRecordRecordId");
            Integer sex = null == map.get("sex") ? -1 :  (Integer) map.get("sex");
            switch (sex) {
                case 0:
                    map.put("sex", sex);
                    map.put("sexStr", "未知");
                    break;
                case 1:
                    map.put("sex", sex);
                    map.put("sexStr", "男");
                    break;
                case 2:
                    map.put("sex", sex);
                    map.put("sexStr", "女");
                    break;
                default:
                    map.put("sex", -1);
                    map.put("sexStr", "未知");
            }
            if (null != map.get("dateOfBirth"))
                map.put("dateOfBirth", DateTools.dateFormat((Date) map.get("dateOfBirth"), DateTools.DATE_FORMAT_YMD));
            Integer residenceType = null == map.get("residenceType") ? -1 :  (Integer) map.get("residenceType");
            switch (residenceType) {
                case 1:
                    map.put("residenceType", residenceType);
                    map.put("residenceTypeStr", "户籍");
                    break;
                case 2:
                    map.put("residenceType", residenceType);
                    map.put("residenceTypeStr", "非户籍");
                    break;
                default:
                    map.put("residenceType", -1);
                    map.put("residenceTypeStr", "未知");
            }
            Integer bloodType = null == map.get("bloodType") ? -1 :  (Integer) map.get("bloodType");
            switch (bloodType) {
                case 1:
                    map.put("bloodType", bloodType);
                    map.put("bloodTypeStr", "A型");
                    break;
                case 2:
                    map.put("bloodType", bloodType);
                    map.put("bloodTypeStr", "B型");
                    break;
                case 3:
                    map.put("bloodType", bloodType);
                    map.put("bloodTypeStr", "O型");
                    break;
                case 4:
                    map.put("bloodType", bloodType);
                    map.put("bloodTypeStr", "AB型");
                    break;
                case 5:
                    map.put("bloodType", bloodType);
                    map.put("bloodTypeStr", "不详");
                    break;
                default:
                    map.put("bloodType", -1);
                    map.put("bloodTypeStr", "未知");
            }
            Integer rHType = null == map.get("rHType") ? -1 :  (Integer) map.get("rHType");
            switch (rHType) {
                case 1:
                    map.put("rHType", rHType);
                    map.put("rHTypeStr", "否");
                    break;
                case 2:
                    map.put("rHType", rHType);
                    map.put("rHTypeStr", "是");
                    break;
                case 3:
                    map.put("rHType", rHType);
                    map.put("rHTypeStr", "不详");
                    break;
                default:
                    map.put("rHType", -1);
                    map.put("rHTypeStr", "未知");
            }
            Integer education = null == map.get("education") ? -1 :  (Integer) map.get("education");
            switch (education) {
                case 1:
                    map.put("education", education);
                    map.put("educationStr", "文盲及半文盲");
                    break;
                case 2:
                    map.put("education", education);
                    map.put("educationStr", "小学");
                    break;
                case 3:
                    map.put("education", education);
                    map.put("educationStr", "初中");
                    break;
                case 4:
                    map.put("education", education);
                    map.put("educationStr", "高中/技校/中专");
                    break;
                case 5:
                    map.put("education", education);
                    map.put("educationStr", "大学专科及以上");
                    break;
                case 6:
                    map.put("education", education);
                    map.put("educationStr", "不详");
                    break;
                default:
                    map.put("education", -1);
                    map.put("educationStr", "未知");
            }
            Integer profession = null == map.get("profession") ? -1 :  (Integer) map.get("profession");
            switch (profession) {
                case 1:
                    map.put("profession", profession);
                    map.put("professionStr", "国家机关、党群组织、企业、事业单位负责人");
                    break;
                case 2:
                    map.put("profession", profession);
                    map.put("professionStr", "专业技术人员");
                    break;
                case 3:
                    map.put("profession", profession);
                    map.put("professionStr", "办事人员和有关人员");
                    break;
                case 4:
                    map.put("profession", profession);
                    map.put("professionStr", "商业、服务员人员");
                    break;
                case 5:
                    map.put("profession", profession);
                    map.put("professionStr", "农、林、牧、渔、水利业生产人员");
                    break;
                case 6:
                    map.put("profession", profession);
                    map.put("professionStr", "生产、运输设备操作人员及有关人员");
                    break;
                case 7:
                    map.put("profession", profession);
                    map.put("professionStr", "军人");
                    break;
                case 8:
                    map.put("profession", profession);
                    map.put("professionStr", "不便分类的其他从业人员");
                    break;
                default:
                    map.put("profession", -1);
                    map.put("professionStr", "未知");
            }
            Integer maritalStatus = null == map.get("maritalStatus") ? -1 :  (Integer) map.get("maritalStatus");
            switch (maritalStatus) {
                case 1:
                    map.put("maritalStatus", maritalStatus);
                    map.put("maritalStatusStr", "未婚");
                    break;
                case 2:
                    map.put("maritalStatus", maritalStatus);
                    map.put("maritalStatusStr", "已婚");
                    break;
                case 3:
                    map.put("maritalStatus", maritalStatus);
                    map.put("maritalStatusStr", "丧偶");
                    break;
                case 4:
                    map.put("maritalStatus", maritalStatus);
                    map.put("maritalStatusStr", "离婚");
                    break;
                case 5:
                    map.put("maritalStatus", maritalStatus);
                    map.put("maritalStatusStr", "未说明的婚姻状况");
                    break;
                default:
                    map.put("maritalStatus", -1);
                    map.put("maritalStatusStr", "未知");
            }
            Integer equipment = null == map.get("equipment") ? -1 :  (Integer) map.get("equipment");
            switch (equipment) {
                case 1:
                    map.put("equipment", equipment);
                    map.put("equipmentStr", "无");
                    break;
                case 2:
                    map.put("equipment", equipment);
                    map.put("equipmentStr", "油烟机");
                    break;
                case 3:
                    map.put("equipment", equipment);
                    map.put("equipmentStr", "换气扇");
                    break;
                case 4:
                    map.put("equipment", equipment);
                    map.put("equipmentStr", "烟囱");
                    break;
                default:
                    map.put("equipment", -1);
                    map.put("equipmentStr", "未知");
            }
            Integer toilet = null == map.get("toilet") ? -1 :  (Integer) map.get("toilet");
            switch (toilet) {
                case 1:
                    map.put("toilet", toilet);
                    map.put("toiletStr", "卫生厕所");
                    break;
                case 2:
                    map.put("toilet", toilet);
                    map.put("toiletStr", "一格或二格粪池式");
                    break;
                case 3:
                    map.put("toilet", toilet);
                    map.put("toiletStr", "马桶");
                    break;
                case 4:
                    map.put("toilet", toilet);
                    map.put("toiletStr", "露天粪坑");
                    break;
                case 5:
                    map.put("toilet", toilet);
                    map.put("toiletStr", "简易棚厕");
                    break;
                default:
                    map.put("toilet", -1);
                    map.put("toiletStr", "未知");
            }
            Integer poultryStall = null == map.get("poultryStall") ? -1 :  (Integer) map.get("poultryStall");
            switch (poultryStall) {
                case 1:
                    map.put("poultryStall", poultryStall);
                    map.put("poultryStallStr", "单设");
                    break;
                case 2:
                    map.put("poultryStall", poultryStall);
                    map.put("poultryStallStr", "室内");
                    break;
                case 3:
                    map.put("poultryStall", poultryStall);
                    map.put("poultryStallStr", "室外");
                    break;
                default:
                    map.put("poultryStall", -1);
                    map.put("poultryStallStr", "未知");
            }
            map.remove("delSign");
            map.remove("lastupTxStamp");
        }
    }

    /*innateServiceEnd*/
    /*以上内容请误删除或是移动，系统升级使用，用户代码请写入下方*/
}
